<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>反馈处理回复</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <link rel="stylesheet" href="../../layui/font/iconfont.eot">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
    <style>
        form {
            float: left;
            display: block !important;
            width: 50%;
        }
        
        .layui-input,
        .layui-textarea {
            display: inline;
            width: 30%;
            cursor: not-allowed;
        }
        
        .layui-input-block {
            position: relative;
        }
        
        .layui-icon {
            position: absolute;
            color: #ccc;
            left: 150px;
            top: 10px;
        }
        
        .biaoti {
            width: 100%;
        }
        
        .neirong {
            width: 100%;
        }
        
        .neirong1 {
            height: 200px;
        }
        
        .tupian {
            border: 1px dashed #ccc;
            border-radius: 12px;
            width: 150px;
            height: 150px;
        }
        
        .tupian1 {
            color: rgb(134, 133, 133);
            top: 56px;
            left: 53px;
            font-size: 12px;
        }
        
        .wenjian {
            position: relative;
            border: 1px dashed #ccc;
            border-radius: 9px;
            width: 60%;
            height: 200px;
        }
        
        .wenjian1 {
            font-size: 45px;
            top: 60px;
            left: 200px;
        }
        
        .shangchuan {
            position: absolute;
            left: 130px;
            top: 120px;
        }
        
        a {
            color: rgb(57, 172, 238);
        }
        
        .shuoming {
            /* position: absolute; */
            margin-top: 8px;
            margin-left: 110px;
            margin-bottom: 18px;
        }
        
        .tubiao {
            border: 1px solid #ccc;
            height: 50px;
        }
        
        .layui-icon_01 {
            color: #000;
            margin-right: 10px;
            font-size: 25px;
        }
        
        .huifuneirong {
            border: 1px solid #ccc;
            border-top: none;
            height: 250px;
        }
        
        hr {
            height: 2px;
            margin: 10px 0;
            border: 0;
            /* clear: both; */
        }
        
        .quxiao {
            position: absolute;
            border: 1px solid #ccc;
            padding: 5px 15px;
            right: 10px;
            float: right;
        }
        
        .tijiao {
            margin-top: 20px;
        }
        
        .dibuanniu {
            margin-left: 60%;
        }
        
        .shuru {
            width: 100%;
            height: 100%;
            cursor: not-allowed;
        }
    </style>
</head>

<body>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>反馈处理回复</legend>
    </fieldset>

    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">所属村</label>
            <div class="layui-input-block">
                <input id="cun" type="text" name="title" disabled="disabled" lay-verify="title" autocomplete="off" placeholder="---" class="layui-input">
                <i class="layui-icon layui-icon-down"></i>

            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">村民</label>
            <div class="layui-input-block">
                <input id="name" type="text" name="username" lay-verify="required" disabled="disabled" placeholder="--" autocomplete="off" class="layui-input">
                <i class="layui-icon layui-icon-down"></i>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">时间</label>
            <div class="layui-input-block">
                <input id="time" type="text" name="time" lay-verify="required" disabled="disabled" placeholder="--" autocomplete="off" class="layui-input biaoti">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标题</label>
            <div class="layui-input-block">
                <input id="title" type="text" name="username" lay-verify="required" disabled="disabled" placeholder="--" autocomplete="off" class="layui-input biaoti">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <textarea id="content" placeholder="--" disabled="disabled" class="layui-textarea neirong"></textarea>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">图片</label>
            <div class="yijiantupian">

            </div>

        </div>
    </form>
    <form class="layui-form" action="">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">回复内容</label>
            <div class="layui-input-block">
                <div class="tubiao">
                    <span class="layui-icon  layui-icon_01 layui-icon-face-smile "></span>
                    <!--   <span class="layui-icon  layui-icon_01 layui-icon-fonts-strong"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-fonts-i"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-fonts-u"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-fonts-del"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-align-left"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-align-center"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-face-right"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-face-smile"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-fonts-code"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-spread-left"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-spread-right"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-link"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-picture"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-spread-left"></span>
                    <span class="layui-icon  layui-icon_01 layui-icon-spread-left"></span> -->

                </div>
                <div class="huifuneirong">
                    <textarea id="huifu" class="shuru deleteAt" disabled name="" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea>

                </div>
            </div>
        </div>
        </div>
    </form>
    <div class="dibuanniu">
        <button class="layui-btn tijiao tijiaofangfa layui-btn-normal layui-btn-disabled" disabled onclick="chuli()">提交</button>
        <button class="layui-btn tijiao  layui-btn-danger" onclick="window.history.back(-1)">返回</button>
    </div>

    <hr>




</body>
<script src="../../layui/layui.js" charset="utf-8"></script>
<script src="../../js/jquery-3.4.1.js"></script>
<script src="../../mock/mock/mock-min.js"></script>
<script src="../../mock/mock1.js"></script>


<script>
    var id

    function huoquid() {
        var index = window.location.href.lastIndexOf("?");
        idinfo = window.location.href.substring(index + 1, window.location.href.length);
        index = idinfo.lastIndexOf("=");
        var id = idinfo.substring(index + 1, window.location.href.length);
        return id
    }
    layui.use(['table', 'form'], function() {

        id = huoquid()
        huoqufankuixinxi(id)
    })

    function huoqufankuixinxi(id) {
        $.ajax({
            url: url + "general/feedback/getfeedbackbyid",
            method: "get",
            data: {
                id: id
            },
            headers: {
                token: localStorage.getItem('token')
            },
            success: function(data) {
                if (data.code === 200 && data.data !== null) {
                    // 未处理
                    if (data.data.processed === 0) {
                        $('.shuru')[0].removeAttribute('disabled')
                        $(".shuru").css("cursor", "auto");
                        $('.tijiaofangfa').removeClass('layui-btn-disabled')
                        $('.tijiaofangfa')[0].removeAttribute('disabled')
                            // 已处理
                    } else if (data.data.processed === 1) {
                        $('#huifu').val(data.data.handlRes)
                    }
                    $('#cun').val(getvillage(data.data.villageId).name)
                    $('#title').val(data.data.title)
                    $('#time').val(timezhuanhuan(data.data.createdAt))
                    $('#content').val(data.data.content)
                    data.data.relatedDocuments = JSON.parse(data.data.relatedDocuments)
                    console.log(data)
                    if (data.data.relatedDocuments == null || data.data.relatedDocuments.length === 0) {
                        $(".yijiantupian")[0].innerHTML += ` 
                        <div class="layui-input-block tupian">
                             <i class="layui-icon  tupian1"> 暂无图片</i>
                        </div>`
                    } else {
                        data.data.relatedDocuments.forEach(item => {
                            $(".yijiantupian")[0].innerHTML += ` <div class="layui-input-block tupian"><img style="width:100%;height:100%;" src="` + item.url + `">  </div>`
                        });
                    }
                    $.ajax({
                        url: url + "villager/getonebyid",
                        method: "get",
                        data: {
                            id: data.data.villagerId
                        },
                        success: function(data) {
                            console.log(data)
                            if (data.data !== null) {
                                $('#name').val(data.data.name)
                            }

                        },
                        error: function(err) {
                            console.log(err)
                        }
                    })
                }
                console.log(data)
            },
            error: function(err) {
                console.log(err)
            }
        })
    }

    function chuli() {
        var data = {}
        data.id = id
        data.handlRes = $('.deleteAt')[0].value
        console.log(data)
        $.ajax({
            url: url + "general/feedback/subdealfeedback",
            method: 'post',
            data: data,
            success: function(data) {
                console.log(data)
                if (data.code === 200) {
                    window.history.back(-1);

                } else {
                    layer.msg('处理失败')
                }
            },
            error: function(err) {
                layer.msg('处理失败')
            }
        })
    }
</script>

</html>